package com.juego.male;

import java.util.Timer;
import java.util.TimerTask;

import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;

import com.juego.utilidades.Animaciones;

public class Splash extends Activity {

	private long splashDelay = 7000; 
	private ImageView ent_uno, rey;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);

		ent_uno = (ImageView)findViewById(R.id.iv_splash1);
		rey = (ImageView)findViewById(R.id.iv_splash2);

		ObjectAnimator traslada = ObjectAnimator.ofFloat(ent_uno, "translationX", -400f, 0.0f);
		traslada.setInterpolator(new LinearInterpolator());
		traslada.setDuration(1000);
		traslada.start();
		traslada.addListener(new AnimatorListener() {

			@Override
			public void onAnimationStart(Animator animation) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onAnimationRepeat(Animator animation) {
				// TODO Auto-generated method stub

			}

			@Override
			public void onAnimationEnd(Animator animation) {
				Animaciones anima = new Animaciones();
				anima.flipCarta(rey, R.drawable.bastos12, true);
			}

			@Override
			public void onAnimationCancel(Animator animation) {
				// TODO Auto-generated method stub

			}
		});

		TimerTask task = new TimerTask() {
			@Override
			public void run() {
				Intent mainIntent = new Intent(getApplication(), Inicio.class);
				startActivity(mainIntent);
				finish();
			}
		};

		Timer timer = new Timer();
		timer.schedule(task, splashDelay);
	}
	
}
